
package format.time;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * 將"現在"的時間, 依 short, medium, long format 成台灣的時間
 * <br>
 * Copyright: Copyright (c) 2001-2007<br>
 * Company: 一零四資訊科技股份有限公司
 * 
 * @author Eric.Kao(eric.kao@104.com.tw)
 * @version 1.0
 */
public class TestDateFormatDispaly
{
	Locale locale = Locale.TAIWAN;

	// Locale locale = Locale.US;

	public TestDateFormatDispaly()
	{
		// short
		System.out.println( format( DateFormat.SHORT, DateFormat.SHORT, locale, "short" ) );

		// medium
		System.out.println( format( DateFormat.MEDIUM, DateFormat.MEDIUM, locale, "medium" ) );

		// long
		System.out.println( format( DateFormat.LONG, DateFormat.LONG, locale, "long" ) );
	}

	public static void main( String[] args )
	{
		new TestDateFormatDispaly();
	}

	private String format( int dateFormat, int timeFormat, Locale locale, String label )
	{
		DateFormat format = DateFormat.getDateTimeInstance( dateFormat, timeFormat, locale );
		
		String date = format.format( new Date() );
		
		return "Date and Time(" + label + "):" + date;
	}
}
